package com.sakura.bean;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author Sakura
 * @Date 2023-02-22 17:17
 */
@Component
public class Pig {//implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    public Pig(){
        System.out.println("pig ..... constructor");
    }

    //对象创建并赋值之后调用
    @PostConstruct
    public void init(){
        System.out.println("pig...... @PostConstruct");
    }

    //容器移除对象之前
    @PreDestroy
    public void destroy(){
        System.out.println("pig ......@PreDestroy ");
    }

//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        this.applicationContext=applicationContext;
//    }
}
